<template>
  <div>
    <h1>Didi</h1>
    <h1>{{count}}</h1>
    <button @click="beybey">拜拜</button>
  </div>
</template>

<script>
import PubSub from 'pubsub-js'
export default {
    name:'Didi',
    data(){
        return {
            count:0,
            pubId:null
        }
    },
    mounted(){
      this.pubId = PubSub.subscribe('count',(_,count) => {
            this.count = count
        })
    },
    methods:{
        beybey(){
            PubSub.unsubscribe(this.pubId)
        }
    }
}
</script>

<style>

</style>